package com.czk.model.iterator.practice;

import java.util.Iterator;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/6/17 22:27
 */
public class ResearchDevelopmentIterator implements Iterator {
    private ResearchDevelopment researchDevelopment;
    // 数组指针
    private int position=0;
    // 传入需要迭代的部门
    public ResearchDevelopmentIterator(ResearchDevelopment researchDevelopment) {
        this.researchDevelopment=researchDevelopment;
    }
    // 是否存在下一个
    @Override
    public boolean hasNext() {
        if (position>researchDevelopment.getPeople().length-1||researchDevelopment.getPeople()[position]==null){
            return false;
        }
        return true;
    }
    // 返回存在的值
    @Override
    public Object next() {
        Person person=researchDevelopment.getPeople()[position];
        position++;
        return person;
    }
}
